home *** CD-ROM | disk | FTP | other *** search
- CHOOSECOLOR API DEMO ⌐ Mike McGrath(UK)1998 emailto:mikem@clara.net
- ====================================================================
-
- This demonstration illustrates the steps required by the windows color dialog box in allowing the
- user to select a color. These steps are normally automated but the demo now requires them to be
- taken manually in order to understand them fully.
-
- DECLARATION:
- ============
- Declare Function ChooseColor Lib "comdlg32" Alias"ChooseColorA" _
- (pChoosecolor As ChooseColor)As Long
-
- VARIABLE STRUCTURE:
- ===================
- Type ChooseColor
- lStructSize As Long (length of variable)
- hwndOwner As Long (handle of calling window)
- hInstance As Long (not used in demo)
- rgbResult As Long (color from 0 to 16777215)
- lpCustColors As String (value of custom color)
- flags As Long (any required flags)
- lCustData As Long (not used in demo)
- lpfnHook As Long (not used in demo)
- lpTemplateName As String (not used in demo)
- End Type
-
- FLAGS:
- ======
- Const CC_RGBINIT = &H1 (open colordialog with selected color set to rgbResult value)
- Const CC_FULLOPEN = &H2 (open colordialog with custom colors already opened)
- Const CC_PREVENTFULLOPEN = &H4 (disable the button which opens custom colors)
- Const CC_SHOWHELP = &H8 (enable the help button)
- Const CC_SOLIDCOLOR = &H80 (return equivalent selected color, for 256 colors or below)
- Const CC_ANYCOLOR = &H100 (return the actual selected color, for 256 colors or below)
-
- VARIABLES:
- ==========
- Dim CustomColors() As Byte (establish array for custom colors)
- Dim MyColor As ChooseColor (to pass selection to variable type structure)
-
- EXECUTION:
- ==========
- MyColor.flags =CC_ANYCOLOR (set flags,"OR" for joint flags)
- MyColor.lStructSize = Len(MyColor) (set size of variable structure)
- MyColor.hwndOwner = Form1.hWnd (get handle of calling window)
- ReDim CustomColor(64) As Byte (make array for custom colors)
- MyColor.lpCustColors = StrConv(CustomColor, vbUnicode) (convert array to string for api)
- x = ChooseColor(MyColor) (call ChooseColor function)
- CustomColor=StrConv(MyColor.lpCustColors,vbFromUnicode) (convert array back from api)
- MyColor.rgbResult (returns chosen color to control)
-
- NOTES:
- ======
- To see purpose of CC_ANYCOLOR and CC_SOLIDCOLOR set screen color depth to 256 colors or less.
- CustomColor byte array stores selected color in rgb format using 4bytes for each selection.
- eg. Byte0(red)=012 Byte1(green)=123 Byte2(blue)=234 Byte3=0 (4th byte is always zero).
- This array must be converted to unicode format before passing to ChooseColor.
-
- CHOOSECOLOR API DEMO ⌐ Mike McGrath(UK)1998 emailto:mikem@clara.net
- Permission is required for anything other than private use of this software and no liability
- whatsoever will be accepted in connection with its use.
-
-
-